package com.hyh.admin.controller.guide;

import com.hyh.ad.common.core.controller.BaseController;
import com.hyh.ad.common.core.domain.AjaxResult;
import com.hyh.admin.service.IIntelligenceGuideService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/guide")
@Api(tags = "智能引导")
public class IntelligenceGuideController extends BaseController {
    @Autowired
    private IIntelligenceGuideService intelligenceGuideService;


    /*
     * 查询所有问题
     */
    @GetMapping("/question")
    @ApiOperation("查询所有问题")
    public AjaxResult listQuestion() {
        return AjaxResult.success(intelligenceGuideService.listQuestion());
    }


    /*
     * 根据parentId查询选项
     */
    @GetMapping("/answer/{parentId}")
    @ApiOperation("查询所有回答 根据parentId")
    public AjaxResult listAnswers(@PathVariable Long parentId) {
        return  AjaxResult.success(intelligenceGuideService.listAnswers(parentId));
    }

    /*
     *  查询问题及答案
     */
    @GetMapping("/questions-with-answers")
    @ApiOperation("查询问题及答案")
    public AjaxResult listQuestionsWithAnswers() {
        return AjaxResult.success(intelligenceGuideService.listQuestionsWithAnswers());
    }

    /*
     * 根据提交的回答id列表查询关联的资源
     */
    @GetMapping("/resources")
    @ApiOperation("根据提交的回答id列表查询关联的资源")
    public AjaxResult listResourcesByAnswerIds(@RequestParam("answerIds") List<String> answerIds) {
        return AjaxResult.success(intelligenceGuideService.listResourcesByAnswerIds(answerIds));
    }
}
